-
-
Notifications
You must be signed in to change notification settings - Fork 98
Add timeout handling for I2C in Wire #497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Also made the default timeout shorter than the 1000 ms that was hardcoded
This should solve the issue #492 |
The actions to reset the hardware in handleTimeout() is not well tested. It would be great if someone who knows better can take a look at it to see if it makes sense and if there should be changes. |
The new logic for the timeout loop in read_from() and write_to() had a bug. It is now fixed.
Adding timeout handling for I2C in Wire according to previously defined solution on other platforms Also reduced the default timeout from 1000ms to 25ms
Fixed a bug in timeout handling in read_from() and write_to() and made the commit cleaner |
After some more testing I conclude that I need even more testing to make sure it works as intended. |
Thanks for your pull request, and for taking the time to provide an update on the situation @HanzHager! I see that one of Arduino's developers also submitted a similar pull request: #494 It would be great if you would review that prior pull request and help us to understand whether your PR provides any advancements when compared to the other, and whether the other might also suffer from any of the potential problems you have identified in testing of this PR. |
I looked at this PR and it looks like it is using setTimeout() instead of setWireTimeout() for the implementation. I have tried to make a complete implementation that harmonizes best with this and the AVR implementation. I am quite new in making contributions like this, so I probably need quite some guidance to get it right. |
I just noticed that #494 have renamed the setTimeout() to setWireTimeout(). The function sets timeout in milliseconds, but the referred implementation https://docs.arduino.cc/language-reference/en/functions/communication/wire/setWireTimeout/ are using microseconds as well as a boolean second parameter that tells the implementation to reset the bus on timeout or not. |
Adding timeout handling for I2C in Wire according to previously defined solution on other platforms
Also reduced the default timeout from 1000ms till 25ms
Also created src directory as well as adding keywords.txt and library.properties so that the "Wire" part of the repository can be handled as a separate library